package com.inventory.api.controller;

import com.inventory.api.service.StockCheckOrderService;
import com.inventory.api.signUpReq.StockCheckSignUpReq;
import com.inventory.api.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by lihu on 2018/2/2.
 */

@Slf4j
@RestController
@RequestMapping(value = "v1/inventory", produces = "application/json;charset=utf-8")
public class StockCheckController {

    @Autowired
    StockCheckOrderService checkOrderService;

    /***
     * 库存盘点
     * @param signUpReq
     * @return
     */
    @RequestMapping(method = RequestMethod.POST, value = "/stock-check")
    public ResponseEntity stoctOut(@RequestBody StockCheckSignUpReq signUpReq) {
        try {
            checkOrderService.StockCheckOrder(signUpReq);
            return new ResponseEntity(new Result(200), HttpStatus.OK);
        } catch (Exception ex) {
            log.error("stoctOut is error==> signUpReq:{}", signUpReq, ex);
            return new ResponseEntity(new Result(500), HttpStatus.OK);
        }
    }
}
